vtd: move the snoop control detection out of acpi_dmar_init()
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Feb 2009 10:54:17 +0000 (10:54 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Feb 2009 10:54:17 +0000 (10:54 +0000)
where the capability value is not initialized thus we may
get random value.

Signed-off-by: Xin, Xiaohui<xiaohui.xin@intel.com>
xen/drivers/passthrough/vtd/dmar.c
xen/drivers/passthrough/vtd/iommu.c

index 8df7b006cd4dbd59761375465b87b24308812e97..946ade0101f120d526c5c3ebb51e07c57a5454ee 100644 (file)
@@ -519,8 +519,6 @@ static int __init acpi_parse_dmar(struct acpi_table_header *table)
 int acpi_dmar_init(void)
 {
     int rc;
-    struct acpi_drhd_unit *drhd;
-    struct iommu *iommu;
 
     rc = -ENODEV;
     if ( force_iommu )
@@ -537,22 +535,7 @@ int acpi_dmar_init(void)
     if ( list_empty(&acpi_drhd_units) )
         goto fail;
 
-    /* Giving that all devices within guest use same io page table,
-     * enable snoop control only if all VT-d engines support it.
-     */
-    if ( iommu_snoop )
-    {
-        for_each_drhd_unit ( drhd )
-        {
-            iommu = drhd->iommu;
-            if ( !ecap_snp_ctl(iommu->ecap) ) {
-                iommu_snoop = 0;
-                break;
-            }
-        }
-    }
-
-    printk("Intel VT-d has been enabled, snoop_control=%d.\n", iommu_snoop);
+    printk("Intel VT-d has been enabled\n");
 
     return 0;
 
index 7bc680eed8f03767c9a344de886f9545ee3d013f..9aaa6400a87a67c1c2587203d2016010f2afad8e 100644 (file)
@@ -1765,6 +1765,23 @@ int intel_vtd_setup(void)
     if ( init_vtd_hw() )
         goto error;
 
+    /* Giving that all devices within guest use same io page table,
+     * enable snoop control only if all VT-d engines support it.
+     */
+
+    if ( iommu_snoop )
+    {
+        for_each_drhd_unit ( drhd )
+        {
+            iommu = drhd->iommu;
+            if ( !ecap_snp_ctl(iommu->ecap) ) {
+                iommu_snoop = 0;
+                break;
+            }
+        }
+    }
+    
+    printk("Intel VT-d snoop control %sabled\n", iommu_snoop ? "en" : "dis");
     register_keyhandler('V', dump_iommu_info, "dump iommu info");
 
     return 0;
@@ -1773,6 +1790,7 @@ int intel_vtd_setup(void)
     for_each_drhd_unit ( drhd )
         iommu_free(drhd);
     vtd_enabled = 0;
+    iommu_snoop = 0;
     return -ENOMEM;
 }